package com.carcenter.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carcenter.common.model.dto.ServiceQueryDto;
import com.carcenter.order.entity.Services;
import com.carcenter.order.mapper.ServicesMapper;
import com.carcenter.order.service.IServicesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author car
 * @since 2025-07-16
 */
@Service
public class ServicesServiceImpl extends ServiceImpl<ServicesMapper, Services> implements IServicesService {
    @Override
    public IPage<Services> getServices(Integer pageNum, Integer pageSize, ServiceQueryDto serviceQueryDto) {
        IPage<Services> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Services> queryWrapper = new LambdaQueryWrapper<>();
        if (serviceQueryDto!=null){
            if (serviceQueryDto.getServiceName()!=null){
                queryWrapper.like(Services::getServiceName,serviceQueryDto.getServiceName());
            }
            if (serviceQueryDto.getStatus()!=null){
                queryWrapper.eq(Services::getStatus,serviceQueryDto.getStatus());
            }
        }
        return  this.page(page, queryWrapper);
    }
}
